<template>
  <div>
    <el-dropdown @command="commentEvent">
      <span style="color: #fff">
        <svg-icon icon-class="language" />
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item command="en" :disabled="$i18n.locale === 'en'">
            English
          </el-dropdown-item>
          <el-dropdown-item
            command="zh"
            :disabled="$i18n.locale === 'zh'"
          >中文</el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<script>
import JsCokkie from 'js-cookie'
export default {
  name: 'Lang',
  //   inject: ['reload', 'fn'],
  methods: {
    commentEvent(command) {
      this.$i18n.locale = command
      JsCokkie.set('lang', command)
      this.$router.go(0)
      //   this.fn(Date.now())
      //   this.reload()
    }
  }
}
</script>

<style></style>
